/**
 * @Project Name:blog-business-service
 * @Package Name:cn.hoofungson.blog.business.service.provider.controller.user
 * @Since JDK 1.8
 */

package cn.hoofungson.blog.business.service.provider.controller.user;

import cn.hoofungson.blog.business.service.interfaces.domain.dto.user.UserDTO;
import cn.hoofungson.blog.business.service.provider.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: UserController
 * @Author 胡松 hoofungson@163.com
 * @Date 2020-03-24 18:56
 * @Version V1.0
 */
@Slf4j
@RequestMapping("/service/user")
@RestController
public class UserServiceController {

    @Autowired
    private UserService userService;

    @GetMapping("/{id}")
    public ResponseEntity<UserDTO> get(@PathVariable("id") Long id) {
        UserDTO userDTO = this.userService.get(id);
        log.info("admin-api获取数据链路, business-service端输出！！");
        return new ResponseEntity<>(userDTO, HttpStatus.OK);
    }

    @GetMapping("/detail/{username}")
    public ResponseEntity<UserDTO> getByUsername(@PathVariable("username") String username) {
        UserDTO userDTO = this.userService.getByUsername(username);
        log.info("admin-api获取数据链路, business-service端输出！！");
        return new ResponseEntity<>(userDTO, HttpStatus.OK);
    }
}
